package com.springcloud.eshop.product.controller;

import com.springcloud.eshop.entity.Category;
import com.springcloud.eshop.product.service.CategoryService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (Category)表控制层
 *
 * @author makejava
 * @since 2020-06-28 23:35:18
 */
@RestController
@RequestMapping("/category")
public class CategoryController {
    /**
     * 服务对象
     */
    @Resource
    private CategoryService categoryService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping("/selectOne")
    @ResponseBody
    public Category selectOne(Long id) {
        return this.categoryService.queryById(id);
    }

    /**
     * @Desc: 插入数据
     * @Param brand
     * @Return com.springcloud.eshop.domain.entity.Brand
     * @Date: 2020/6/28
     */
    @RequestMapping("/insert")
    @ResponseBody
    public Category insert(Category category) {
        return this.categoryService.insert(category);
    }

    @RequestMapping("/update")
    @ResponseBody
    public Category update(Category category) {
        return this.categoryService.update(category);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public boolean deleteById(Long id) {
        return this.categoryService.deleteById(id);
    }

}